/*
 * @Author: zds
 * @Date: 2022-10-28 15:05:32
 * @LastEditors: zds
 * @LastEditTime: 2022-11-10 15:35:38
 * @Description: file content
 * @FilePath: \qjt-app\src\provide.js
 */
export default
    {
        convertUrl: function (item, parmas) {
            var url = "";
            // 项目定位
            if (item.serverCode == "gcdw") {
                this.$f7.request({
                    url: "/project/position/getByEngineeId",
                    type: "POST",
                    data: { engineeId: parmas.engineeId },
                    async: false,
                    cache: false,
                    dataType: "json",
                    success: (res) => {
                        if (res.parameters.caseId) {
                            this.$f7.request({
                                url: "/workflow/getWorkflowArgs",
                                type: "POST",
                                data: { formId: res.parameters.caseId },
                                async: false,
                                cache: false,
                                dataType: "json",
                                success: (result) => {
                                    url = (
                                        item.serverUrl +
                                        `?caseId=${res.parameters.caseId}&engineeId=${parmas.engineeId}&pageAction=edit&taskId=${result.taskId || result.historyTaskId}&assigneeId=${result.assigneeId}&version=${result.version}&appCode=positionCase`
                                    );
                                },
                                timeout: (result) => {
                                    result.success = false;
                                    result.message = "登录超时";
                                },
                            });
                        } else {
                            //新增
                            url = (
                                item.serverUrl +
                                `?engineeId=${parmas.engineeId}&pageAction=create&appCode=positionCase`
                            );
                        }
                    },
                    timeout: (result) => {
                        result.success = false;
                        result.message = "登录超时";
                    },
                });
            }
            // 人员签到
            if (item.serverCode == "ryqd") {
                let role = ['BUILD_MANAGER', 'IOS_ROLE']
                role = role.map(item => {
                    item = item.toLowerCase()
                    return item
                })
                if (this.$framework.account.hasRole(role)) {
                    url = `/business/construction/enginee/signin/record?engineeId=${parmas.engineeId}`
                }
            }
            return url;
        },
    }
